package IC.AST.nodes;

import IC.AST.*;

/**
 * an if statement
 */
public class IfStmt extends Statement {
	private Expression condition;	// the if condition
	private Statement ifStmt;	// the if statement
	private Statement elseStmt;	// the else statement

	/**
	 * @param condition the if condition
	 * @param ifStmt the if statement
	 * @param elseStmt the else statement
	 * @param fileName TODO
	 * @param line the node line number
	 * @param column the node column number
	 */
	public IfStmt(Expression condition, Statement ifStmt, Statement elseStmt, String fileName, int line, int column) {
		super(fileName, line,column);
		this.condition = condition;
		this.ifStmt = ifStmt;
		this.elseStmt = elseStmt;
	}

	/**
	 * @return the if condition
	 */
	public Expression getCondition() {
		return this.condition;
	}

	/**
	 * @return the if statement
	 */
	public Statement getIfStmt() {
		return this.ifStmt;
	}

	/**
	 * @return the else statement
	 */
	public Statement getElseStmt() {
		return this.elseStmt;
	}

	public <D,U> U accept(PropogatingVisitor<D,U> v, D context) throws Exception {
		return v.visit(this,context);
	}
}
